package cn.stronglink.asset.module.ipParam.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.IdWorker;
import cn.stronglink.asset.model.IpParam;
import cn.stronglink.asset.module.ipParam.mapper.IpParamMapper;
import cn.stronglink.suite.core.util.WebUtil;

@Service
@Transactional(rollbackFor = Exception.class)
public class IpParamService {

	@Autowired
	private IpParamMapper ipParamMapper;

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page<IpParam> queryList(Page<IpParam> page, Map<String, Object> params) {
		List<IpParam> list = ipParamMapper.queryList(page, params);
		page.setRecords(list);
		return page;
	}

	/***
	 * 新增ipAddress表
	 * @param repair
	 * @return
	 */
	public int create(IpParam param) {
		param.setId(IdWorker.getId());
		param.setCreateBy(WebUtil.getCurrentUser());
		param.setCreateTime(new Date());
		int count = ipParamMapper.insertIpParam(param);
		return count;
	}

	/***
	 * 更新
	 * @param ipAddress
	 */
	public void edit(IpParam ipParam) {
		ipParam.setUpdateTime(new Date());
		ipParam.setUpdateBy(WebUtil.getCurrentUser());
		// 更新维修单
		ipParamMapper.updateIpParam(ipParam);
	}

	/***
	 * 删除
	 * @param id
	 */
	public void remove(Long id) {
		ipParamMapper.remove(id);
	}

	/***
	 * 获取ipAddress信息
	 * @param id
	 */
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public IpParam qryById(Long id) {
		return  ipParamMapper.qryById(id);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<IpParam> queryIpParamList() {
		List<IpParam>  list = ipParamMapper.queryIpParamList();
		return list;
	}

	
}
